//package com.nifty.base.mq.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitAdmin;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.beans.factory.config.ConfigurableBeanFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.PropertySource;
//import org.springframework.context.annotation.Scope;
//
//@Configuration
//@PropertySource("rabbitMq.properties")
//@Slf4j
//public class RabbitMqConfig {
//
//    @Value("${META-INF.rabbitmq.host}")
//    private static String host;
//    @Value("${META-INF.rabbitmq.username}")
//    private static String userName;
//    @Value("${META-INF.rabbitmq.password}")
//    private static String password;
//    @Value("${META-INF.rabbitmq.port}")
//    private static int port;
//    @Value("${META-INF.rabbitmq.queue}")
//    private static String queueName;
//    @Value("${META-INF.rabbitmq.vhost}")
//    private static String vhost;
//    @Value("${META-INF.rabbitmq.publisher-confirms}")
//    private static boolean publisherConfirms;
//
//    @Bean
//    public ConnectionFactory connectionFactory(){
//        CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
//        connectionFactory.setAddresses(host);
//        connectionFactory.setUsername(userName);
//        connectionFactory.setPassword(password);
//        connectionFactory.setVirtualHost(vhost);
//        connectionFactory.setPublisherConfirms(publisherConfirms); //必须要设置
//        return connectionFactory;
//    }
//
//    //rabbitmq的模板配置
//    @Bean
//    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) //必须是prototype类型
//    public RabbitTemplate rabbitTemplate() {
//        RabbitTemplate template = new RabbitTemplate(connectionFactory());
//        //template.setConfirmCallback(); 设置消息确认
//        //template.setReturnCallback();
//        return template;
//    }
//
//    @Bean
//    public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
//        return new RabbitAdmin(connectionFactory());
//    }
//}